import { _decorator,Component,Label, Sprite, SpriteFrame,Node} from "cc";
import { GameResult } from "../Cmd/GameResult";
import { Utils } from "../Common/Utils";
const { ccclass, property } = _decorator;
@ccclass
export  class GameResultItem extends Component {
   
   
    @property(Label)
    private ID!:Label;

    @property(Label)
    private Bet!:Label;

    @property(Label)
    private Select!:Label;

    @property(Sprite)
    private Result!:Sprite;

    @property(Node)
    private WinFlag!:Node;

    @property(Label)
    private Prize!:Label;

    @property({ type: SpriteFrame })
    redSpriteFrame: SpriteFrame = null;

    @property({ type: SpriteFrame })
    blackSpriteFrame: SpriteFrame = null;

    public setData(data: any) {
        const itemData = data as GameResult;
        this.ID.string =itemData.id+'';
        this.Bet.string =Utils.num1000(itemData.fee) +'';
        this.Select.string = itemData.prize>0?itemData.item==1?('Red'):('Black'):itemData.item!=1?('Red'):('Black');
        this.WinFlag.active=itemData.prize>0;
        this.Result.spriteFrame = itemData.item==1?this.redSpriteFrame:this.blackSpriteFrame;
        this.Prize.string = Utils.num1000(itemData.prize) ; 
        
    }
}